var id = getQueryString('id')
var bookname = getQueryString('bookname')
$(".thisbook").html(bookname)
$.ajax({
	url: baseurl + `/bookDetail/detail?id=${id}`,
	type: 'get',
	dataType: 'json',
	success: function (e) {
        console.log(e)
        $(".title").html(e.data.name)
        // $(".gs").html(e.data.content)
        var con= e.data.content;
        var duan = con.split('\n')
        for(var k=0;k<duan.length;k++){
            var section = `<p>${duan[k].trim()}<p>`
            $(".content").append(section)
        }
        $(".thisbook").attr("href",`book.html?id=${e.data.bookId}`)
        $(".menulist a").attr("href",`book.html?id=${e.data.bookId}&tab=1`)
	}
});
// 上下
function topage(u,t,a){
    $.ajax({
        url: baseurl + u,
        type: 'get',
        dataType: 'json',
        success: function (e) {
            if(e.success){
                var _id = e.data.id
                t.html(`<a href="read.html?bookname=${bookname}&id=${_id}">${a}</a>`)
            }else{
                t.html(`<a>${a}</a>`)
                t.addClass("nopage")
            }
            
        }
    });
}
topage(`/bookDetail/prev?id=${id}`,$(".prev"),"上一章")
topage(`/bookDetail/next?id=${id}`,$(".next"),"下一章")